/** Biorhythmix
 * @author Vitaliy Lagutin
 * @version 1.0
 */

import java.util.Calendar;
import java.util.GregorianCalendar;

class CalculDaysLife {
	int daysum = 0;

	int[] yPoint0 = new int[61]; int[] yPoint1 = new int[61]; int[] yPoint2 = new int[61]; int[] yPoint3 = new int[61];
	int[] xPoint = new int[61];

	Calendar tmp = GregorianCalendar.getInstance();
	int nd = tmp.get(Calendar.DAY_OF_MONTH); // current day
	int nm = tmp.get(Calendar.MONTH) + 1;    // current month
	int ny = tmp.get(Calendar.YEAR);         // current year
	
	CalculDaysLife(int bd, int bm, int by) {
		int[][] biorhythms = new int[4][61];

		int[] daymonth = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		double[] biocycles = new double[] {23.688437, 28.426125, 33.163812};

		// Расчет расчет количества дней прошедших с дня рождения по текущий день
		if (by != ny) daysum = (daymonth[bm-1] - bd) + 1;
	
		if (by != ny) {
			for (int i = bm; i < 12; i++)
				daysum += daymonth[i];
		}
		if ( (by % 4 == 0) && (bm < 3) ) daysum = daysum + 1;
		for (int i = by + 1; i < ny; i++) {
			daysum += 365;
			if (i % 4 == 0) daysum += 1;
		}
		if (by != ny) {
			for (int i = 0; i < nm-1; i++)
				daysum += daymonth[i];
			if (ny % 4 == 0 && nm > 2) daysum += 1;
         daysum += nd;
		}
		if ( (by == ny) && (bm != nm) ) {
			for (int i = bm; i < nm; i++)
				daysum += daymonth[i];
		}
		if ( (by == ny) && (by % 4 == 0) && (bm <= 2) && (nm > 2) ) daysum += 1;
		if (by == ny && bm != nm) daysum += nd;
		if (by == ny && bm == nm) daysum = nd - bd + 1;
		
		// calculation of biorhythms				
		for (byte i = 0; i < 3; i++) {
			for (byte e = 0; e < 61; e++) {
				biorhythms[i][e] = (int) Math.round( Math.sin (  (2 * Math.PI * (daysum + (e - 30))) / biocycles[i] ) * 100 );
			}
		}

		// Присваивание координат				
		for (int i = 0; i < 61; i++) {
			yPoint0[i] = (int) Math.round( -1.5 * biorhythms[0][i] + 150 );
			yPoint1[i] = (int) Math.round( -1.5 * biorhythms[1][i] + 150 );
			yPoint2[i] = (int) Math.round( -1.5 * biorhythms[2][i] + 150 );
		}
		xPoint[0] = 0;
		for (int i = 1; i < 61; i++)
			xPoint[i] = xPoint[i-1] + 10;
	}
}